"""
Author: Morphlng
Date: 2024-12-14 20:36:47
LastEditTime: 2024-12-16 23:04:55
LastEditors: Morphlng
Description: 
FilePath: /DrivingGym/src/driving_gym/environment/agent/reward/base_reward.py
"""

from __future__ import annotations

from driving_gym.data.data_provider import Snapshot
from driving_gym.environment.scenario.base_scenario import BaseScenario
from driving_gym.simulation.adapter_interface import AdapterInterface


class BaseReward:
    def __init__(self, config: dict, adapter: AdapterInterface = None):
        self.config = config.copy()
        self.adapter = adapter
        self.type: str = config.get("type", "default")
        self.params: dict = config.get("params", {})
        self.cache: dict = {}

        # This is automatically set by the environment
        self.actor_id: str = self.config["actor_id"]

    def reset(self):
        self.cache = {}

    def get_reward(
        self, snapshot: Snapshot, scenario: BaseScenario
    ) -> tuple[float, dict]:
        """Return reward value and details of each reward component."""
        return 0.0, {}
